<html>
<head><meta charset="utf-8"><title>GAT syntax whining · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/GAT.20syntax.20whining.html">GAT syntax whining</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="248271339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/GAT%20syntax%20whining/near/248271339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/GAT.20syntax.20whining.html#248271339">(Aug 03 2021 at 19:53)</a>:</h4>
<p>The location of this <code>where</code> clause feels all sorts of wrong:</p>
<div class="codehilite"><pre><span></span><code>type Item&lt;&#39;a&gt; where Self: &#39;a = &amp;&#39;a mut [T];
</code></pre></div>
<p>I'm sure there's a good reason for it. Why can't it be</p>
<div class="codehilite"><pre><span></span><code>type Item&lt;&#39;a&gt; = &amp;&#39;a mut [T]
where
    Self: &#39;a;
</code></pre></div>



<a name="248273645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/GAT%20syntax%20whining/near/248273645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/GAT.20syntax.20whining.html#248273645">(Aug 03 2021 at 20:09)</a>:</h4>
<p>I will admit that it seems to make more sense for the <code>where</code> clause to be after the type</p>



<a name="248278378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/GAT%20syntax%20whining/near/248278378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/GAT.20syntax.20whining.html#248278378">(Aug 03 2021 at 20:48)</a>:</h4>
<p>My brain does a bit of a segfault when I see <code>'a = &amp;'a</code>. Then I backtrack and try to make <code>'a = &amp;'a mut [T]</code> into a trait.</p>



<a name="248278681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/GAT%20syntax%20whining/near/248278681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/GAT.20syntax.20whining.html#248278681">(Aug 03 2021 at 20:50)</a>:</h4>
<p>The current order has parallels with other kinds of items where the <code>where</code> is between the name and body.</p>



<a name="248281261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/GAT%20syntax%20whining/near/248281261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/GAT.20syntax.20whining.html#248281261">(Aug 03 2021 at 21:08)</a>:</h4>
<p>I think the the RHS is conceptually more of a 'header' than a 'body' here</p>



<a name="248281281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/GAT%20syntax%20whining/near/248281281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/GAT.20syntax.20whining.html#248281281">(Aug 03 2021 at 21:08)</a>:</h4>
<p>similar to how we have <code>fn foo() where Type: Trait {}</code></p>



<a name="248281361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/GAT%20syntax%20whining/near/248281361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/GAT.20syntax.20whining.html#248281361">(Aug 03 2021 at 21:09)</a>:</h4>
<p>and I also had trouble reading <code>type Item&lt;'a&gt; where Self: 'a = &amp;'a mut [T];</code> - it looked like we were assigning to the <code>Self: 'a</code>,</p>



<a name="248281994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/GAT%20syntax%20whining/near/248281994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/GAT.20syntax.20whining.html#248281994">(Aug 03 2021 at 21:13)</a>:</h4>
<p>normal type aliases can already have bounds in that place right now in stable Rust, even if not enforced</p>



<a name="248320020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/GAT%20syntax%20whining/near/248320020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/GAT.20syntax.20whining.html#248320020">(Aug 04 2021 at 07:51)</a>:</h4>
<p>Even if we don't change it in the grammar, the parser will need to be able to do so, because I fully expect people to try to write them both ways...</p>



<a name="248323928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/GAT%20syntax%20whining/near/248323928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Giacomo Stevanato <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/GAT.20syntax.20whining.html#248323928">(Aug 04 2021 at 08:40)</a>:</h4>
<p>Note however that this is kinda inconsistent with trait aliases since they're written as <code>trait Alias = Supertrait where SomeType: SomeBound;</code><br>
However changing this makes it inconsistent with how supertraits are defined since you have to put them before the where clauses.</p>



<a name="248341423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/GAT%20syntax%20whining/near/248341423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/GAT.20syntax.20whining.html#248341423">(Aug 04 2021 at 12:13)</a>:</h4>
<p>If we will be inconsistent with some other part of Rust anyway, I'd propose changing it away from the current form <span aria-label="innocent" class="emoji emoji-1f607" role="img" title="innocent">:innocent:</span> .</p>
<p>Has anyone talked with a rustfmt developer about how the current form would be formatted?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>